<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>添加印章</title>
    <link rel="stylesheet" href="/asset/layui/css/layui.css">
    <link rel="stylesheet" href="/asset/css/index.css">
    <link rel="Shortcut Icon" href="cachet.ico">
    <script type="text/javascript" src="/asset/js/jquery-3.3.1.min.js"></script>
	<script src="/asset/layui/layui.js"></script>
    <script src="/asset/js/common.js"></script>
    
  
    
</head>
<body >
<div class="alert_bigbox">

	<form class="layui-form">
          <div class="layui-form-item">
              <label for="devicesCode" class="layui-form-label">选择机构</label>
              <div class="layui-input-inline">
              	  <select name="orgId">
			        <option value="">请选择机构</option>
			        <#list orgs as item>
			        <option value="${item.organizationId}">${item.name}</option>
			        </#list>
			      </select>
              </div>
          </div>
          <div class="layui-form-item">
              <label for="L_repass" class="layui-form-label">
              </label>
              <button  class="layui-btn" lay-filter="add" lay-submit="">确定添加</button>
          </div>
      </form>
</div>

    <script>
        layui.use(['form','layer','laydate'], function(){
            $ = layui.jquery,form = layui.form,layer = layui.layer,laydate = layui.laydate;
          
          //监听提交
          form.on('submit(add)', function(data){
          
          var field = data.field;
          
          var $ids =  parent.right.$("input[name='ids']:checked");
          if($ids.length <=0 ){
           	layer.msg('请选择员工');
           	return false;
          }
          
          if(!field.orgId){
          	layer.msg('请选择机构');
           	return false;
          }
          
          $ids.each(function(i,item){
          	var id = $(this).val();
          	field['ids['+i+']'] = id;
          })
          
          
          
            $.ajax({
      			type:"POST", 
      			url:"/staff/setting/post.htm",
      			data:field,
      			success:function(result) {
		      
		      		if(result.code=='1'){
		      			layer.alert("增加成功", {icon: 6},function () {
			                // 获得frame索引
			                parent.document.getElementById('rightMain').contentWindow.location.reload(true);
			                var index = parent.layer.getFrameIndex(window.name);
			                //关闭当前frame
			                parent.layer.close(index);
			            });
		      		}else{
		      		 	layer.msg(result.msg);
		      		}
		      
		    	 	} 
		    }); 
            
            return false;
          });
          
        });
    </script>

</body>
</html>